<template>
  <div>
    <h2>语法树展示</h2>
    <Tree :tree="treeJson"></Tree>
  </div>
</template>

<script type="text/javascript">
import Walker from '@/walker';
import TreeWalker from '@/walker/tree';
import code from '@/code/program';

const acorn = require('acorn');

export default {
  data() {
    const tree = acorn.parse(code);

    const treeJson = new Walker(TreeWalker, {}).walk(tree);

    return {
      treeJson,
    };
  },
};
</script>

<style type="text/css">
</style>
